package 面试;

public class 整数N有几个二进制1 {


    private static int countOnes(int num) {
        int count = 0;
        while (num != 0) {
            num = num & (num - 1);
            count++;
        }
        return count;
    }

    public static void main(String[] args) {
        System.out.println(countOnes(15));
    }
}
